<?php
require dirname(dirname(dirname(__FILE__))).'/include/user-verify.php';
include dirname(dirname(__FILE__)).'/user-manage/functions.php';
include dirname(__FILE__).'/functions.php';
$cur_user = getUserById($_SESSION['user_id']);
$exchange_item = getExchangeByToUserId($_SESSION['user_id']);
$from_user = getUserById($exchange_item['from_user_id']);
$duty_user_list = getCurDutyUser();
$duty_user_list['']='';
$table = json_decode($exchange_item['table_content'],true);
?>
<!DOCTYPE html>
<html>
	<head>
		<?php include dirname(dirname(dirname(__FILE__))).'/include/common-header.php'; ?>
		<link rel="stylesheet" type="text/css" href="../css/style.css">
	</head>
	<body>
			<div class="col-md-12">
				<div>
					<h3> 来自<?php echo $from_user['user_real_name']?>的换班请求</h3>
				</div>
				<div>
			        <table class="table table-striped table-bordered table-hover table-condensed " id="default-table">
					  <tr>
					  	<th>#</th>
					  	<th>星期一</th>
					  	<th>星期二</th>
					  	<th>星期三</th>
					  	<th>星期四</th>
					  	<th>星期五</th>
					  	<th>星期六</th>
					  	<th>星期天</th>
					  </tr>
					  <?php 
					  $time = array();
					  $time['a']='7:30~10:00';$time['b']='10:00~12:30';
					  $time['c']='12:30~14:30';$time['d']='14:30~16:00';
					  $time['e']='16:00~18:30';$time['f']='18:30~22:30';
					  foreach(range('a', 'f') as $item) {
					  	echo '<tr>';
					  	echo '<td style="vertical-align:middle;">'.$time[$item].'</td>';
					  	for($i=1;$i<=7;$i++) {
					  		echo '<td>';
					  		if($table[$i][$item]<0) {
					  			echo '<span style="color:#F10909">';
					  			if((-$table[$i][$item])==$cur_user['id']) {
					  				echo $from_user['user_real_name'].'=>'.$cur_user['user_real_name'];
					  			} else echo $cur_user['user_real_name'].'=>'.$from_user['user_real_name'];
					  			echo '</span>';
					  		} else echo '<span>'.$duty_user_list[$table[$i][$item]].'</span>';
					  		echo '</td>';
					  	}
					  	echo '</tr>';
					  }
					  ?>
					</table>
					<span><b>换班理由:</b></span>
					<textarea class="form-control" rows="5" style="width:60%;margin-bottom:30px;" readonly><?php echo $exchange_item['remark']; ?></textarea>
			   <a href="approve-exchange.php" class="btn btn-primary">同意换班</a>
			   <a href="reject-exchange.php" class="btn btn-danger">拒绝换班</a>
			</div>
		</div>
	</body>
</html>